package at.jku.ase.communication.parsers;

import at.jku.ase.communication.SessionObject;

import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

/**
 * Created by IntelliJ IDEA.
 * User: stellit
 * Date: 12/19/11
 * Time: 9:20 AM
 * To change this template use File | Settings | File Templates.
 */
public class FeedbackParser extends ComponentParser {

    public FeedbackParser(final SessionObject session, final XMLResponse action) {
        super(session, action);
    }

    @Override
    protected Object processRequest(XMLStreamReader reader) throws XMLStreamException {
        int next = reader.next();
        if ( next == XMLStreamConstants.CHARACTERS) {
            System.out.println("Parsing feedback from server...");
            String status = reader.getText();
            getSession().setSignStatus("OK".equals(status) ? true : false);
        }
        return null;
    }

}
